package enumDemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * 单例模式
 * 是不可以通过反射来拿到枚举的私有构造方法
 */
public class constant {
	public static final int RED = 1;
	public static final int WHITE = 2;
	public static final int GREEN = 3;

	public static void main(String[] args)  {
		Class<?> c1;
		try {
			c1=Class.forName("enumDemo.TestEnum");
			Constructor<TestEnum> con=(Constructor)c1.getDeclaredConstructor(String.class,int.class,String.class,int.class);
			con.setAccessible(true);
			TestEnum testEnum=con.newInstance("ceshi",99,"zhaoliu",99);
			System.out.println(testEnum);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		} catch (NoSuchMethodException e) {
			throw new RuntimeException(e);
		} catch (InvocationTargetException e) {
			throw new RuntimeException(e);
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}

	}
}
